home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Prog / Q-R / QDPat.cpt / Dialog_1.Pas next >
Encoding:
Pascal/Delphi Source File  |  1989-10-21  |  3.9 KB  |  123 lines  |  [TEXT/PJMM]

  1. unit Dialog_1;
  2.  
  3. {File name:  Dialog_1.Pas  }
  4. {Function: Handle a dialog}
  5. {History: 10/6/89 Original by Prototyper.   }
  6. {                       }
  7.  
  8.  
  9. interface
  10.  
  11.     uses
  12.         Utilities;
  13.  
  14.  
  15.  
  16.     procedure D_Dialog_1;
  17.  
  18. implementation
  19.  
  20.     const                               {These are the item numbers for controls in the Dialog}
  21.         I_x = 1;
  22.         I_Picture1 = 2;
  23.     var
  24.         ExitDialog: boolean;           {Flag used to exit the Dialog}
  25.         DoubleClick: boolean;          {Flag to say that a double click on a list happened}
  26.         MyPt: Point;                   {Current list selection point}
  27.         MyErr: OSErr;                  {OS error returned}
  28.  
  29. {===========================================================}
  30.  
  31.     function MyFilter (theDialog: DialogPtr; var theEvent: EventRecord; var itemHit: integer): boolean;
  32.         var
  33.             tempRect: Rect;
  34.  
  35.     begin
  36.         MyFilter := FALSE;
  37.         if (theEvent.what = MouseDown) then{Only do on a mouse click}
  38.             begin
  39.                 MyPt := theEvent.where;{Get the point where the mouse was clicked}
  40.                 GlobalToLocal(MyPt);        {Convert global to local}
  41.  
  42.  
  43.             end;
  44.     end;
  45.  
  46. {===========================================================}
  47.  
  48.  
  49.     procedure D_Dialog_1;
  50.         var
  51.             GetSelection: DialogPtr;{Pointer to this dialog}
  52.             tempRect: Rect;            {Temporary rectangle}
  53.             DType: Integer;            {Type of dialog item}
  54.             Index: Integer;            {For looping}
  55.             DItem: Handle;             {Handle to the dialog item}
  56.             CItem, CTempItem: controlhandle;{Control handle}
  57.             sTemp: Str255;             {Get text entered, temp holding}
  58.             itemHit: Integer;          {Get selection}
  59.             temp: Integer;             {Get selection, temp holding}
  60.             dataBounds: Rect;          {Rect to setup the list}
  61.             cSize: Point;              {Pointer to a cell in a list}
  62.             Icon_Handle: Handle;       {Temp handle to read an Icon into}
  63.             NewMouse: Point;           {Mouse location during tracking Icon presses}
  64.             InIcon: boolean;           {Flag to say pressed in an Icon}
  65.             ThisEditText: TEHandle; {Handle to get the Dialogs TE record}
  66.             TheDialogPtr: DialogPeek;{Pointer to Dialogs definition record, contains the TE record}
  67.  
  68.     {This is an update routine for non-controls in the dialog}
  69.     {This is executed after the dialog is uncovered by an alert}
  70.         procedure Refresh_Dialog;           {Refresh the dialogs non-controls}
  71.             var
  72.                 rTempRect: Rect;             {Temp rectangle used for drawing}
  73.  
  74.         begin
  75.             SetPort(GetSelection);      {Point to our dialog window}
  76.         end;
  77.  
  78.  
  79.     begin                               {Start of dialog handler}
  80.         GetSelection := GetNewDialog(1, nil, Pointer(-1));{Bring in the dialog resource}
  81.         ShowWindow(GetSelection);{Open a dialog box}
  82.         SelectWindow(GetSelection);{Lets see it}
  83.         SetPort(GetSelection);      {Prepare to add conditional text}
  84.  
  85.         TheDialogPtr := DialogPeek(GetSelection);{Get to the inner record}
  86.         ThisEditText := TheDialogPtr^.textH;{Get to the TE record}
  87.         HLock(Handle(ThisEditText));{Lock it for safety}
  88.         ThisEditText^^.txSize := 12;{TE Point size}
  89.         TextSize(12);               {Window Point size}
  90.         ThisEditText^^.txFont := systemFont;{TE Font ID}
  91.         TextFont(systemFont);       {Window Font ID}
  92.         ThisEditText^^.txFont := 0;{TE Font ID}
  93.         ThisEditText^^.fontAscent := 12;{Font ascent}
  94.         ThisEditText^^.lineHeight := 12 + 3 + 1;{Font ascent + descent + leading}
  95.         HUnLock(Handle(ThisEditText));{UnLock the handle when done}
  96.  
  97.  
  98.             {Setup initial conditions}
  99.         Refresh_Dialog;             {Draw any Lists, popups, lines, or rectangles}
  100.  
  101.         ExitDialog := FALSE;          {Do not exit dialog handle loop yet}
  102.  
  103.         repeat                      {Start of dialog handle loop}
  104.             ModalDialog(nil, itemHit);{Wait until an item is hit}
  105.             GetDItem(GetSelection, itemHit, DType, DItem, tempRect);{Get item information}
  106.             CItem := Pointer(DItem);{Get the control handle}
  107.  
  108.                 {Handle it real time}
  109.             if (ItemHit = I_Picture1) then{Handle the Picture}
  110.                 begin
  111.                 end;                    {End for this item selected}
  112.             Wait(10);
  113.             ExitDialog := TRUE;{Exit the dialog}
  114.  
  115.         until ExitDialog;           {Handle dialog items until exit selected}
  116.  
  117.             {Get results after dialog}
  118.  
  119.         DisposDialog(GetSelection);{Flush the dialog out of memory}
  120.  
  121.     end;                            {End of procedure}
  122.  
  123. end.                                {End of unit}